package io.renren.modules.simida.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.simida.entity.UserFundLogEntity;
import io.renren.modules.simida.service.UserFundLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户金币金额收入支出日志
 *
 * @author miaoguoxin
 * @email ${email}
 * @date 2019-11-22 15:30:43
 */
@RestController
@RequestMapping("simida/userfundlog")
public class UserFundLogController {
    @Autowired
    private UserFundLogService userFundLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("simida:userfundlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userFundLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("simida:userfundlog:info")
    public R info(@PathVariable("id") Long id){
        return R.ok().put("userFundLog", userFundLogService.queryById(id));
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("simida:userfundlog:save")
    public R save(@RequestBody UserFundLogEntity userFundLog){
		userFundLogService.save(userFundLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("simida:userfundlog:update")
    public R update(@RequestBody UserFundLogEntity userFundLog){
		userFundLogService.updateById(userFundLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("simida:userfundlog:delete")
    public R delete(@RequestBody Long[] ids){
		userFundLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
    * @Description: 订单补偿操作
    * @Param:
    * @return:
    * @Author: miaoguoxin
    * @Date: 2019/11/22
    */
    @RequiresPermissions("simida:userfundlog:update")
    @PutMapping("/compensate")
    public R compensatePay(@RequestBody String[] tradeNos){
        userFundLogService.compensatePay(Arrays.asList(tradeNos));
        return R.ok();
    }
}
